﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using IDAL;

namespace DAL
{
    /// <summary>
    /// 攻略分类
    /// </summary>
    public class D_StrategType:IStrategType
    {
        WishDayEntities _es;
        public D_StrategType()
        {
            _es = new WishDayEntities();
        }

        public void Add(StrategType obj)
        {
            _es.StrategType.Add(obj);
            _es.SaveChanges();
        }

        public void Delete(int id)
        {
            _es.StrategType.Remove(_es.StrategType.Find(id));
            _es.SaveChanges();
        }

        public StrategType FindById(int id)
        {
            return _es.StrategType.Find(id);
        }

        public List<StrategType> GetAll()
        {
            return _es.StrategType.ToList();
        }

        public void Update(int id, StrategType obj)
        {
            var data = _es.StrategType.Find(id);
            data.STypeName = obj.STypeName;
            data.STPower = obj.STPower;
            data.Show = obj.Show;
            data.CreateTime = obj.CreateTime;
            _es.SaveChanges();
        }
    }
}
